A data processing device, for example, a microprocessor, is constituted by an assembly of digital electronic circuits (hardware) for executing instructions stored in a suitable program (software). A typical instruction comprises a sequence of binary digits (bits) and includes a part which indicates the type of operation to be executed (operation code), and a part which enables the data to be operated on (the operand field) to be identified. A data processing device generally utilizes various addressing modes to access this data. In particular, in immediate addressing, the data is specified by referring directly to its value in the instruction (immediate operand). This method of addressing is particularly useful when constant values are to be used. In the immediate addressing method, therefore, N bits of the operand field are needed to represent 2.sup.N different constant values.
Various solutions are known for reducing the number of bits necessary for representing constant values in instructions intended to contain data to be addressed immediately. In so-called short constant systems, only Q bits (where Q&lt;N) of lesser significance of the constant are represented in the operand field, obtaining the bits of greater significance thereof by sign extension or zero filling. In particular, in the case of sign extension, all the bits of the constant from the position Q+1 to the position N-1 are given the same value as the sign bit in position Q, while in the case of zero filling, these bits of the constant are given the value 0. The values which can be represented lie, respectively, in the range -2.sup.Q-1 to 2.sup.Q-1 -1, and the range 0 to 2.sup.Q -1. In single bit systems, the constants having a single bit with a value of 1 are represented by indicating the position of this bit in the constant. In this case, a number of bits P is necessary, given by the relationship N=2.sup.P, that is, P=log.sub.2 N. This system is usually used for instructions at the single bit level for clear, set, test, and toggle operations.
A disadvantage of the known systems is that only certain types of constants can be represented shortened. These systems therefore impose severe limitations both on the value of the representable constants and on their structure.
In addition, the set of reduced length constants represented in the known systems is fixed and is independent of the different operative requirements of the data processing device.
What is needed is a method and device for overcoming the aforesaid disadvantages.